package com.tanhua.server.service;

import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.tanhua.common.mapper.UserInfoMapper;
import com.tanhua.common.pojo.UserInfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    public UserInfo queryById(Long id) {
        QueryWrapper<UserInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",id);
        UserInfo userInfo = userInfoMapper.selectOne(wrapper);
        if (userInfo==null){
            return null;
        }
        return userInfo;
    }
    //查询ud对应的结果集
    public List<UserInfo> queryUserInfoList(List<Object> users) {
        QueryWrapper<UserInfo> query = new QueryWrapper<>();
        query.in("user_id",users);
        return this.userInfoMapper.selectList(query);
    }
    public List<UserInfo> queryUserInfoList(QueryWrapper<UserInfo> queryWrapper) {
        return this.userInfoMapper.selectList(queryWrapper);
    }
    //更新信息
    public Boolean updateUserInfoByUserId(UserInfo userInfo) {
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",userInfo.getUserId());
       return this.userInfoMapper.update(userInfo,queryWrapper)>0;
    }
}
